home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS09.ADF
/
MyCLI
/
MyCLI.DOC
< prev
next >
Wrap
Text File
|
1986-05-22
|
17KB
|
363 lines
MyCLI, a command line interpreter and its history.
-------------------------------------------------
Version 1.00 by Mike Schwartz. ( Posted December 1985 )
344 Fay Way, Mt. View, CA 94043
Version 1.01 by Rick Wirch ( added line editing, redirection, etc. )
1009 Vilas Ave. #2, Madison, WI 53715
Version 1.02 by D.J. James ( added phase of moon to date )
Version 1.03 and Version 2.0 by Rick Wirch ( revised until May 86 )
Overview
--------
MyCLI is a command shell interpreter, intended as a substitute for the
AmigaDOS Command Line Interpreter. It has twenty four built-in commands
such as 'dir', 'delete', 'type', 'cd' and 'copy'. Since these programs are
internal to MyCLI, you do not need a Workbench diskette inserted in any
drive to perform these tasks. The other alternative to using MyCLI is to
copy commands into the RAM: disk device. Copying all the commands MyCLI
provides into the RAM: disk would use 60688 bytes.
MyCLI is only 17580 bytes long, and provides many features that make
the CLI much easier to use such as command line editing.
The command line editing uses the arrow keys, delete, backspace, and has
overstrike or insert modes. MyCLI also remembers the last sixteen
commands, which can be recalled with the up and down arrow keys. This
allows reuse of commands without re-typing.
Another ability of MyCLI is its user definability. It allows you to
define up to twenty commands for the function keys and shifted function
keys. Once a function key is defined your favorite command is just a
keystroke away! MyCLI also lets you define a command search path. Now
commands can reside in areas other than the current directory or in the 'C'
( command ) directory of the disk you booted with.
Finally, it lets you define the string for your prompt ( including the
current path ), and the character used to chain multiple commands together
on a single line. All of these definable features can be set to your
liking in a file called 'AUTOEXEC.BAT' that will be executed when MyCLI
starts up.
It has an optional internal terminal program as well, with ASCII file
send and receive, and ANSI terminal compatibility. Unfortunately, I do not
have a modem and the code is relatively untouched from the original version
by Mike Schwartz. Therefore, I cannot account for its abilities or
inabilities. The reports I have heard from people who have beta tested
MyCLI is that MyCLI is easily overrun at 1200 baud.
That is why there are two versions of MyCLI on the AMICUS #9 disk. One
has all of the modem commands and abilities included and the other does
not. Personally, I would rather use one of the public domain modem
programs on the other AMICUS disks for going online and use MyCLI as a CLI
replacement only.
The program can be found on AMICUS disk #9 or the executable can be
found in the AMIGA sections on the PeopleLink or CompuServe networks.
Because of the excessive length of the source code, 54966 bytes, it will
not be found in this magazine.
To use this program you must invoke it from the command line interface
(CLI). I recommend copying it to your 'c' directory on your boot disk, so
MyCLI becomes a built-in command. I also recommend typing "run MyCLI" as
opposed to typing "MyCLI" so that the plain CLI still works.
Command line editing
--------------------
Cursor left and right move the cursor left and right through the
currently typed characters on the command line. Shift of the cursor left
and right move to the beginning and end of the line, respectively. The
delete key deletes the character under the cursor, and backspace deletes
the character to the left of the cursor and moves the rest of the line
left.
The TAB key or CTRL-A ( for you VMS users ) toggles insert/overstrike
mode. The default mode is overstrike mode, so any characters typed in the
middle of a line overstrike the present characters. TAB changes to insert
mode, where newly typed characters are inserted into the command line
string at the current cursor position.
The ESC key and CTRL-X are both 'kill' characters and will erase the
current command line.
Cursor up and down recall the previous sixteen command lines. This is a
simple 'history' function. These previous commands may be edited as if
they were just typed at the keyboard. Thus a command involving a long path
could be recreated with a new file by simply hitting cursor up, cursoring
to the file name and entering in the new file name in the same path.
.CLI files, .BAT files, and MyCLI search paths
----------------------------------------------
When a new command is typed and return is pressed, the first word in the
line is the command name. AmigaDOS would search the current directory,
then the C: directory, for a program file with this name.
MyCLI will first search its internal list of twenty-two commands for the
command name. If it is not found in the internal list it will search for
a file with the command name, and a '.BAT' extension in the current
directory. If this file is found, it is executed in a similar fashion as
the MyCLI AUTOEXEC.BAT batch file. (See below.)
If no '.BAT' file is found, MyCLI next searches for a file with the
extension '.CLI' in the current directory. If this file is found, it is
sent to AmigaDOS, as if 'EXECUTE commandname.CLI' was typed.
Finally, if no '.CLI' file is found, the command is searched for in the
user defined search path. This user defined search path consists of paths
or complete directory desriptions separated by semi-colons. If the path
ends in a directory name it must have a trailing '/' ( slash ). The '.'
( period ) is reserved to mean the current directory. The command search
path is searched from left to right and the first path where the command is
found is used.
To make life easier for single drive MyCLI users I have copied the 'Run'
command into the RAM: disk, and assigned the default place for commands to
be the 'C' directory in the RAM: disk. If you have a program that fails
because it cannot find a command enter this line, "assign C: SYS:C". Also
if you dislike MyCLI's versions of 'delete' and 'copy' enter these lines.
"copy SYS:C/Copy RAM:C", "copy SYS:C/Delete RAM:C"
Now, if you type 'copy' MyCLI copies using its internal command, and if you
type 'Copy' MyCLI copies using the command in the RAM: disk. The same goes
for any commands typed using any upper case letters.
AUTOEXEC.BAT file
-----------------
If a file named AUTOEXEC.BAT is found in the current directory when
MyCLI starts, it is executed immediately. For example, this file might
change the prompt string to your liking, and define your function keys.
This file can contain both MyCLI commands and AmigaDOS commands, but
don't try to use IF, SKIP, .KEY, or any other batchfile commands because
they will not work correctly.
Help
----
To see a list of MyCLI commands, press the Help key.
Internal MyCLI commands Example
----------------------- -------------
> redirect command output dir opt a > filename
< redirect command input myprog < inputfile
The file redirection can now be at any place within the command
string, unlike AmigaDOS. Unfortunately the '<' does not work entirely
and I have been stymied for weeks how to correct the problem. The
problem lies within the AmigaDOS Execute() command (for you programmers
out there) and I am sure you know what an awful mess that function is
if you have ever used it.
Within the AmigaDOS Execute() function also lies one of the bugs
that MyCLI has. Actually it is not a bug but a strange quirk. If
you type a command that is not internal to MyCLI, and that command
requires you to type in some information, you have to select the window
MyCLI was spawned from, press <RETURN>, and type the input in that
window. The output will occur on the MyCLI window though. If anyone
knows how to cure this, please send a update, I know quite a few people
who have this same problem with other programs.
cd change current directory cd df1:source
The cd command in MyCLI also understands the meaning of leading
slashes in a directory name. For example if you are in the directory
df0:include/exec/update and you type 'cd //devices' you will end up two
levels higher, in the directory df0:include/devices.
copy copy a file copy df0:c/diskcopy ram:c
This command works significantly faster than the AmigaDOS copy
command. It uses as large a buffer as possible to copy the file.
It also works like MS-DOS 'copy', because using one parameter copies a
file to the same name, in the current directory, unlike AmigaDOS 'copy'.
Either filename can be '*', to specify the console, and the devices PRT:,
SER:, PAR:, CON: are allowed. The copy command does not allow patterns
( wild carding ), or the keyword 'all' though.
(Also, if you have not weaned yourself from using the 'FROM' and 'TO'
keywords with the AmigaDOS 'copy' command, this command will understand.)
date display the date date
Date shows the date, the day of the week, and the phase of the moon.
This command was reworked and the phase of the moon was added by D.J.
James. It does not display the time, or allow you to set the date or
time. To set the date or time use 'Date', the AmigaDOS version.
define set a function key definition define f1 dir ram:
def " " def f2 run online cis
There are twenty user-definable function keys, from f1 to f20.
The functions f11 through f20 refer to SHIFTed function keys. To
remove a function key definition type 'define f#', where # is the number
of the function key to remove.
delete delete a file delete df1:mydir/myfile
del " " del bah.c
Delete deletes a file, but does not allow any patterns or wildcarding
in the file to be deleted. It also does not allow multiple file names to
be specified or the keyword 'all'.
dir directory listing dir df1:include opt a
ls " " ls df0:mydir
The 'dir' and 'ls' commands can use either the 'opt a' or the '-r'
keywords to recurse down any subdirectories encountered in the specified
or the current path. You cannot use the keywords 'opt i' or 'opt d'.
(Yes, you can say 'ls opt a', or 'dir -r', for that matter.)
endcli exit to the previous CLI endcli
help display simple help listing help
list directory listing list ram:
List gives all the information about a file like the 'List' command
in AmigaDOS, but it cannot recurse down directories. It also cannot
use the keywords 'PAT', 'KEYS', 'DATES', 'NODATES', 'QUICK', etc. to
change the way this information is displayed.
makedir make a new directory makedir RAM:C
md " " md examples
more view a text file, a page at a time more mycli.c
The <SPACEBAR> will advance the listing by a page, the RETURN key
will advance the listing a line at a time, and ESCAPE or CTRL-C will
cancel the listing immediately.
rename rename a file or subdirectory rename documents as texts
mv " " mv file.c backup.c
newcli birth another MyCLI task newcli 0 0 640 200 2
New MyCLI task windows will appear on the right side, with each
new window slightly higher than the previous window if no parameters
are given. If parameters are given they are the X position, Y position,
width, height, and MyCLI id or process number. If MyCLI is started
with a process number other than '1' it will not copy 'run' into the
RAM: disk, and it will not assign C: to the RAM: disk.
set set system variables set prompt = $e[1;32m$p> $n
The variables are 'path', 'prompt', and 'chain'. If you just type
set path<RETURN> or set 'variable'<RETURN> the current value of the
variable is displayed. If you type a string after the variable name
( the '=' is optional ) that string is copied into the variable you
specified.
The 'path' variable is a string defining the command search path.
That is, when a command is to be executed it is searched for in all the
directories from left to right in the search path.
The 'chain' variable is the character used to separate several
commands on the same line.
See the discussion of prompt expansion strings below.
setcomment set the comment on a file setcomment foo.c A comment.
time show current time time
type type a file, without pausing. type hackhack.txt
This command sends a file to the standard output, which can be
redirected, the <SPACEBAR> can be used to start/stop the display and
ESC or CTRL-C can be used to abort the command at any time.
whatis convert AmigaDOS error code to text whatis 203
-----------------------------------------------------------------------
If the internal modem program is enabled, these additional commands are
available. (Please note that the modem program code is removed from
some versions of MyCLI, to save space.)
terminal enter dumb terminal mode
online " "
CTRL-C will allow you to re-enter MyCLI and enter one command, after
that command is completed you will go back into terminal mode. If you
do not see what you are typing, you can type CTRL-E to toggle local
echoing. This feature is useful when you are connected to another
personal computer that does not echo characters back to you.
offline terminate modem communication
capture begin/end ASCII file capture, that is 'capture' is a toggle.
The 'type' command will send a file over the communications port
as well as display it on the screen.
Prompt string escapes
---------------------
MyCLI understands several prompt string escapes which begin with a '$'.
Here are the available escapes. They may be in upper- or lower-case.
$b backspace prints a destructive backspace character
$d date 14-May-86
$e escape char ^[, the ASCII escape character.
This may be used to change text color or video mode, or underlines,
italics, bold, etc. using ANSI video escape sequences.
$n normal video change text back to normal video
$p path This expands to the current path string.
Note that this is the path as understood by MyCLI. If you switch
disks in DF1:, the path string will stay the same. If you type 'dir',
it will request the first disk.
$r reverse video change text to reversed or inverse video
$t time This expands to the time, 13:24:56.
$v version This expands to the version of MyCLI.
This is currently "MyCli rev. 2.0".
$_ newline This expands to the newline character.
For example, the default MyCLI prompt is:
$e[1;32m$p> $n
This displays a prompt in boldface color 3, followed by the current path,
and then a '>'. The video is returned to normal colors.
Credits
-------
The development of MyCLI is indebted to Mike Schwartz, who wrote a simple
command line interpreter replacement. The source code retains his
authorship message. His internal modem program code is untouched and
untested, so there may be bugs, of course.
The command line editing, history ability, definable paths, chain
characters, redirection capabilities, improvements in definable prompts,
recursive directory command, more command, and set command were implemented
by Rick Wirch. I also fixed bugs and generally rewrote the the cd, copy,
define, dir, newcli, and type commands to improve their performance and
abilities. Finally, I ran a fine-toothed comb through the code and reduced
the size of the executable from about 40K in its original form to its
current 17K ( with the help of AZTEC 'C' ) and in the process removed all
the bugs ( I hope ).
P.S. I use MyCLI every day on the average of four hours per day and I have
not found any bugs in it with the exception of Execute() and its creaping
featureisms.
Version 1.00 by Mike Schwartz, 344 Fay Way, Mt. View CA 94043
Version 2.0 by Rick Wirch, 1009 Vilas Ave. #2, Madison, WI 53715